<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:s="http://jboss.com/products/seam/taglib"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:a4j="http://richfaces.org/a4j">
		<a4j:loadScript src="resource://jquery.js"></a4j:loadScript>
		<a4j:form id="BuyForm" styleClass="trn_form" ajaxSingle="true">
		<rich:jQuery selector="#j_id694:BuyForm:buyHeadStamping" timing="onload" query="focus()" />
			<a4j:outputPanel id="msgContainer" ajaxRendered="true">
				<h:messages globalOnly="false" errorClass="msgError" styleClass="message" infoClass="msgInfo" />
			</a4j:outputPanel>
			<a4j:outputPanel id="PurchaseHeadPanel">
				<div id="PurchaseHead">
				
				<div class="form_table">
					<div class="form_row">
						<div class="form_fields">
							<s:label for="buyHeadStamping">Timbrado:</s:label>
							<h:inputText
								styleClass="input"
								value="#{trnPurchase.purchasesHead.stamping}"
								id="buyHeadStamping" 
								size="10">
                    			<a4j:support event="onchange"></a4j:support>
                    			<rich:ajaxValidator 
                    			event="onblur" 
                    			onsubmit="validateStringField(
                    				fieldObject = this, 
                    				fieldMsgId = 'buyHeadStampingMsg', 
                    				required = 'true', 
                    				requiredMsg = 'Favor ingrese el Timbrado', 
                    				chekForLength = 'false', 
                    				min = 0, 
                    				max = 0)">
           						</rich:ajaxValidator>
							</h:inputText>
							<div id="buyHeadStampingMsg" class="inactiveMsg"></div>
						</div>
						<div class="form_fields">
							<s:label for="buyHeadEstablishment">Establecimiento:</s:label>
							<h:inputText
								styleClass="input required"
								value="#{trnPurchase.purchasesHead.establishment}"
								id="buyHeadEstablishment" 
								size="5"
								validatorMessage="El Establecimiento debe contener 3 caracteres">
								<a4j:support event="onchange"></a4j:support>
                    			<rich:ajaxValidator 
                    			event="onblur" 
                    			onsubmit="validateStringField(
                    				fieldObject = this, 
                    				fieldMsgId = 'buyHeadEstablishmentMsg', 
                    				required = 'true', 
                    				requiredMsg = 'Favor ingrese el Establecimiento', 
                    				chekForLength = 'false', 
                    				min = 0, 
                    				max = 0)">
           						</rich:ajaxValidator>
							</h:inputText>
							<div id="buyHeadEstablishmentMsg" class="inactiveMsg"></div>
						</div>
						<div class="form_fields">
							<s:label for="buyHeadExpedition">Punto Expedicion:</s:label>
							<h:inputText
								styleClass="input"
								value="#{trnPurchase.purchasesHead.expedition}"
								id="buyHeadExpedition" 
								size="5"
								validatorMessage="El Punto de expedicion debe contener 3 caracteres">
								<a4j:support event="onchange"></a4j:support>
								<rich:ajaxValidator 
                    			event="onblur" 
                    			onsubmit="validateStringField(
                    				fieldObject = this, 
                    				fieldMsgId = 'buyHeadExpeditionMsg', 
                    				required = 'true', 
                    				requiredMsg = 'Favor ingrese el Punto de Expedicion', 
                    				chekForLength = 'false', 
                    				min = 0, 
                    				max = 0)">
           						</rich:ajaxValidator>
							</h:inputText>
							<div id="buyHeadExpeditionMsg" class="inactiveMsg"></div>
						</div>
						<div class="form_fields">
							<s:label for="buyHeadVoucher">Nro. Factura:</s:label>
							<h:inputText
								styleClass="input"
								value="#{trnPurchase.purchasesHead.voucher}"
								id="buyHeadVoucher" size="10">
								<a4j:support event="onchange"></a4j:support>
								<rich:ajaxValidator 
                    			event="onblur" 
                    			onsubmit="validateStringField(
                    				fieldObject = this, 
                    				fieldMsgId = 'buyHeadVoucherMsg', 
                    				required = 'true', 
                    				requiredMsg = 'Favor ingrese el Nro. de Factura', 
                    				chekForLength = 'false', 
                    				min = 0, 
                    				max = 0)">
           						</rich:ajaxValidator>
							</h:inputText>
							<div id="buyHeadVoucherMsg" class="inactiveMsg"></div>
						</div>
					</div>
					<div class="form_row">
						<div class="form_fields">
							<s:label for="buyHeadVoucherData">Tipo de Comprobante:</s:label>
							<h:selectOneMenu 
								styleClass="input"
								value="#{trnPurchase.purchasesHead.voucherData}"
								id="buyHeadVoucherData" 
								converter="#{voucherConverter}">
								<a4j:support event="onchange" />
								<rich:ajaxValidator 
                    			event="onblur" 
                    			onsubmit="validateSelectField(
                    				fieldObject = this, 
                    				fieldMsgId = 'buyHeadVoucherDataMsg', 
                    				required = 'true', 
                    				requiredMsg = 'Favor seleccione el Tipo de Comprobante')">
           						</rich:ajaxValidator>
								<s:selectItems
									value="#{withinHolder.voucherListPurchases()}"
									var="voucher" label="#{voucher.descrip}"
									noSelectionLabel="Tipo de Comprobante">
								</s:selectItems>
	
							</h:selectOneMenu>
							<div id="buyHeadVoucherDataMsg" class="inactiveMsg"></div>
						</div>
						<div class="form_fields">
							<s:label for="buyHeadBuyType">Tipo de Compra:</s:label>
							<h:selectOneMenu
								styleClass="input"
								value="#{trnPurchase.purchasesHead.buyTypeData}"
								id="buyHeadBuyType" converter="#{refConverter}">
								<a4j:support event="onchange" />
								<rich:ajaxValidator 
                    			event="onblur" 
                    			onsubmit="validateSelectField(
                    				fieldObject = this, 
                    				fieldMsgId = 'buyHeadBuyTypeMsg', 
                    				required = 'true', 
                    				requiredMsg = 'Favor seleccione el tipo de compra')">
           						</rich:ajaxValidator>
								<s:selectItems
									value="#{withinHolder.refDetListByHeadCod('TIPCOMPRA')}"
									var="ref" label="#{ref.descrip}"
									noSelectionLabel="Tipo de Compra">
								</s:selectItems>
	
							</h:selectOneMenu>
							<div id="buyHeadBuyTypeMsg" class="inactiveMsg"></div>
						</div>
						<div class="form_fields">
							<s:label for="buyHeadBuyCondition">Condicion Compra:</s:label>
							<h:selectOneMenu
								styleClass="input"
								converter="#{buyConditionConverter}"
								value="#{trnPurchase.purchasesHead.buyConditionData}"
								id="buyHeadBuyCondition">
								<a4j:support event="onchange" />
								<rich:ajaxValidator 
                    			event="onblur" 
                    			onsubmit="validateSelectField(
                    				fieldObject = this, 
                    				fieldMsgId = 'buyHeadBuyConditionMsg', 
                    				required = 'true', 
                    				requiredMsg = 'Favor seleccione la Condicion de Compra')">
           						</rich:ajaxValidator>
								<s:selectItems 
									value="#{withinHolder.buyConditionList()}"
									var="buyCond" 
									label="#{buyCond.descrip}"
									noSelectionLabel="Condicion de compra">
								</s:selectItems>
							</h:selectOneMenu>
							<div id="buyHeadBuyConditionMsg" class="inactiveMsg"></div>
						</div>
						<div class="form_fields">
							<s:label for="buyHeadCostCenter">Centro de Costo:</s:label>
							<h:selectOneMenu
								styleClass="input"
								value="#{trnPurchase.purchasesHead.costCenterData}"
								id="buyHeadCostCenter" 
								converter="#{refConverter}">
								<a4j:support event="onchange" />
								<rich:ajaxValidator 
                    			event="onblur" 
                    			onsubmit="validateSelectField(
                    				fieldObject = this, 
                    				fieldMsgId = 'buyHeadCostCenterMsg', 
                    				required = 'true', 
                    				requiredMsg = 'Favor seleccione el Centro de Costo')">
           						</rich:ajaxValidator>
								<s:selectItems
									value="#{withinHolder.refDetListByHeadCod('CENTCOST')}"
									var="ref" label="#{ref.descrip}"
									noSelectionLabel="Centro de Costo">
								</s:selectItems>
							</h:selectOneMenu>
							<div id="buyHeadCostCenterMsg" class="inactiveMsg"></div>
						</div>
					</div>
					<div class="form_row">
						<div class="form_fields">
							<s:label for="buyHeadSupplier">Proveedor:</s:label>
							<h:inputText
								readonly="true"
								styleClass="input"
								value="#{trnPurchase.purchasesHead.supplierData}"
								id="buyHeadSupplier"
								converter="#{supplierConverter}">
								<a4j:support event="onchange" reRender="buyHeadOrderPanel" />
								<rich:ajaxValidator 
                    			event="onblur" 
                    			onsubmit="validateStringField(
                    				fieldObject = this, 
                    				fieldMsgId = 'buyHeadSupplierMsg', 
                    				required = 'true', 
                    				requiredMsg = 'Favor seleccione el proveedor')">
           						</rich:ajaxValidator>
							</h:inputText>
							<a4j:commandLink
							id="selectPurchaseSupplier"
							action="#{trnPurchase.selectHolder.supplierPickList()}"
							oncomplete="#{rich:component('supplierPickModalPanel')}.show()"
							ajaxSingle="true"
							reRender="buySupplierListForm">
								<h:graphicImage value="/img/icons/table_multiple.png" />
							</a4j:commandLink>
							<rich:toolTip for="selectPurchaseSupplier" value="Seleccionar Proveedor"></rich:toolTip>
							<div id="buyHeadSupplierMsg" class="inactiveMsg"></div>
						</div>
						<a4j:outputPanel id="buyHeadOrderPanel">
						<h:panelGroup styleClass="form_fields" rendered="#{trnPurchase.activeOrderQuery()}">
							<s:label for="buyHeadOrder">Nro. Pedido:</s:label>
							<h:selectOneMenu
								styleClass="input"
								value="#{trnPurchase.purchasesHead.orderHeadData}"
								id="buyHeadOrder" converter="#{orderHeadConverter}" required="false">
								<a4j:support event="onchange" action="#{trnPurchase.fillFromOrder()}" reRender="BuyForm, PurchaseDetForm, insDetailBtn"/>
								
								<s:selectItems
									value="#{withinHolder.supplierOrdersList(trnPurchase.purchasesHead.supplierData.id)}"
									var="ord" 
									label="#{ord.orderNumber.toString()}"
									noSelectionLabel="Numero de Pedido">
								</s:selectItems>
							</h:selectOneMenu>
							<div id="buyHeadOrderMsg" class="inactiveMsg"></div>
						</h:panelGroup>
						</a4j:outputPanel>
						<div class="form_fields">
							<s:label for="buyHeadCurrency">Moneda:</s:label>
							<h:selectOneMenu
								styleClass="input"
								converter="#{currencyConverter}"
								value="#{trnPurchase.purchasesHead.currencyData}"
								id="buyHeadCurrency">
								<a4j:support event="onchange"
									actionListener="#{trnPurchase.retrieveChangeType()}"
									reRender="buyHeadChangeTypePanel"
									ajaxSingle="true" />
								<rich:ajaxValidator 
                    			event="onblur" 
                    			onsubmit="validateSelectField(
                    				fieldObject = this, 
                    				fieldMsgId = 'buyHeadCurrencyMsg', 
                    				required = 'true', 
                    				requiredMsg = 'Favor seleccione la moneda')">
           						</rich:ajaxValidator>
								<s:selectItems 
									value="#{withinHolder.currencyList()}" 
									var="cur"
									label="#{cur.descrip}" 
									noSelectionLabel="Seleccione la Moneda">
								</s:selectItems>
							</h:selectOneMenu>
							<div id="buyHeadCurrencyMsg" class="inactiveMsg"></div>
						</div>
						<a4j:outputPanel id="buyHeadChangeTypePanel">
							<div class="form_fields">
								<s:label for="buyHeadChangeType">Tipo de Cambio:</s:label>
								<h:inputText
									styleClass="input"
									value="#{trnPurchase.purchasesHead.changeType}"
									id="buyHeadChangeType" 
									size="10" 
									disabled="true">
									<a4j:support event="onchange" />
									<a4j:support event="onblur"></a4j:support>
								</h:inputText>
								<div id="buyHeadChangeTypeMsg" class="inactiveMsg"></div>
							</div>
						</a4j:outputPanel>
					</div>
					<div class="form_row">
						<div class="form_fields">
							<s:label for="buyHeadVoucherDate">Fecha Factura:</s:label>
							<rich:calendar 
								inputClass="input"
								id="buyHeadVoucherDate"
								value="#{trnPurchase.purchasesHead.voucherDate}" 
								datePattern="dd/M/yyyy hh:mm:a"
								buttonClass="field_btn">
								<a4j:support event="oninputchange"></a4j:support>
								<rich:ajaxValidator 
                    			event="oninputblur" 
                    			onsubmit="validateDateField(
                    				fieldObject = this, 
                    				fieldMsgId = 'buyHeadVoucherDateMsg', 
                    				required = 'true', 
                    				requiredMsg = 'Favor ingrese la fecha de factura',
                    				beforeToday = 'false', 
                    				afterToday = 'false', 
                    				inMonth = 'true')">
           						</rich:ajaxValidator>
           						<rich:ajaxValidator 
                    			event="onchanged" 
                    			onsubmit="validateDateField(
                    				fieldObject = this, 
                    				fieldMsgId = 'buyHeadVoucherDateMsg', 
                    				required = 'true', 
                    				requiredMsg = 'Favor ingrese la fecha de factura',
                    				beforeToday = 'false', 
                    				afterToday = 'false', 
                    				inMonth = 'true')">
           						</rich:ajaxValidator>
							</rich:calendar>
							<div id="buyHeadVoucherDateMsg" class="inactiveMsg"></div>	
						</div>
					</div>
				</div>
			</div>
			</a4j:outputPanel>
			
			<a4j:region id="PurchaseDetForm">
				<a4j:outputPanel id="DetGridPanel">	
				<rich:datascroller align="center" for="PurchaseDetGrid"
						maxPages="15" page="#{dataTableScrollerBean.scrollerPage}"
						renderIfSinglePage="false" />			   			
				<div style="clear: both;" />
				<rich:panel styleClass="table_add" style="margin-top:10px;" rendered="true">
					<rich:dataTable id="PurchaseDetGrid" value="#{trnPurchase.allPurchasesDet}" var="row">
						<f:facet name="header">
							<rich:columnGroup>
								<rich:column rowspan="2">
									<h:selectBooleanCheckbox 
										id="selectAllPurchaseDet" 
										value="#{trnPurchase.selectedAll}" 
										onclick="this.blur()"
										disabled="#{empty trnPurchase.allPurchasesDet}">
							        	<a4j:support event="onchange" actionListener="#{trnPurchase.selectAll}" reRender="PurchaseDetGrid"/>
							      	</h:selectBooleanCheckbox>
							      	<rich:toolTip for="selectAllPurchaseDet" value="Seleccionar Todo"></rich:toolTip>
							      	<a4j:commandLink
							      		rendered="#{not empty trnPurchase.allPurchasesDet}"
							      		disabled="#{not empty trnPurchase.purchasesHead.orderHeadData}"
							      		id="deleteSelectedPurchaseDet"
										action="#{trnPurchase.deleteSelected()}"
										reRender="DetGridPanel, PurchaseDetGrid">
										<h:graphicImage value="/img/icons/table_delete.png" />
									</a4j:commandLink>
									<rich:toolTip for="deleteSelectedPurchaseDet" value="Eliminar Seleccionados"></rich:toolTip>
								</rich:column>
								<rich:column>
									<h:outputText value="Insumo" />
								</rich:column>
								<rich:column>
									<h:outputText value="Unidad de Medida" />
								</rich:column>
								<rich:column>
									<h:outputText value="I.V.A." />
								</rich:column>
								<rich:column>
									<h:outputText value="Cantidad" />
								</rich:column>
								<rich:column>
									<h:outputText value="Costo" />
								</rich:column>
								<rich:column>
									<h:outputText value="Descuento" />
								</rich:column>
								<rich:column>
									<h:outputText value="Recargo" />
								</rich:column>
								<rich:column rowspan="2">
									<a4j:commandButton 
										id="buyInsDetailBtn" 
										action="#{trnPurchase.insertDetail()}"
										value="Insertar" 
										reRender="DetGridPanel" 
										disabled="#{not empty trnPurchase.purchasesHead.orderHeadData}"
										onclick="onRequestStart();"
										oncomplete="onRequestEnd();"/>
								</rich:column>
							
								<rich:column breakBefore="true">
									<h:selectOneMenu converter="#{suppliesConverter}"
										value="#{trnPurchase.purchasesDet.supplyData}" 
										id="buyDetSupply"
										disabled="#{not empty trnPurchase.purchasesHead.orderHeadData}" >
										<a4j:support event="onchange" actionListener="#{trnPurchase.retrieveSupplyData()}" reRender="taxPanel, buyDetCostPanel"/>
										<rich:ajaxValidator 
		                    			event="onblur"
		                    			onsubmit="validateSelectField(
		                    				fieldObject = this, 
		                    				fieldMsgId = 'buyDetSupplyMsg', 
		                    				required = 'true', 
		                    				requiredMsg = 'Favor seleccione el insumo',
		                    				errorClass = 'msgErrorDet',
		                    				errorInput = 'inputErrorDet')">
		           						</rich:ajaxValidator>
										<s:selectItems id="SuplySelect"
											value="#{withinHolder.suppliesList()}" var="supp"
											label="#{supp.descrip}" noSelectionLabel="Insumo">
										</s:selectItems>
									</h:selectOneMenu>
									<div id="buyDetSupplyMsg" class="inactiveMsg"></div>
								</rich:column>
								<rich:column>
									<h:selectOneMenu converter="#{MeasureUnitConverter}"
										value="#{trnPurchase.purchasesDet.measureUnitData}"
										id="buyDetMeasureUnit" required="false"
										requiredMessage="Favor Seleccione la Unidad de Medida"
										disabled="#{not empty trnPurchase.purchasesHead.orderHeadData}">
										<a4j:support event="onchange" actionListener="#{trnPurchase.retrieveSupplyCost()}" reRender="buyDetCostPanel"></a4j:support>
										<rich:ajaxValidator 
		                    			event="onblur"
		                    			onsubmit="validateSelectField(
		                    				fieldObject = this, 
		                    				fieldMsgId = 'buyDetMeasureUnitMsg', 
		                    				required = 'true', 
		                    				requiredMsg = 'Favor seleccione la UM',
		                    				errorClass = 'msgErrorDet',
		                    				errorInput = 'inputErrorDet')">
		           						</rich:ajaxValidator>
										<s:selectItems value="#{withinHolder.measureUnitList()}"
											var="cur" label="#{cur.descrip}" noSelectionLabel="">
										</s:selectItems>
									</h:selectOneMenu>
									<div id="buyDetMeasureUnitMsg" class="inactiveMsg"></div>
								</rich:column>
								
								<rich:column>
									<a4j:outputPanel id="taxPanel" >
									<h:selectOneMenu converter="#{taxConverter}"
										value="#{trnPurchase.purchasesDet.taxData}" id="buyDetIva"
										disabled="true">
										<s:selectItems value="#{withinHolder.taxesList()}" var="cur"
											label="#{cur.descrip}">
										</s:selectItems>
									</h:selectOneMenu>
									</a4j:outputPanel>
								</rich:column>
								
								<rich:column>
									<h:inputText value="#{trnPurchase.purchasesDet.quantity}"
										id="buyDetQuantity"  
										size="10"
										disabled="#{not empty trnPurchase.purchasesHead.orderHeadData}">
										<a4j:support event="onchange"></a4j:support>
										<rich:ajaxValidator 
		                    			event="onblur"
		                    			onsubmit="validateDecimalField(
		                    				fieldObject = this, 
		                    				fieldMsgId = 'buyDetQuantityMsg', 
		                    				required = 'true', 
		                    				requiredMsg = 'Favor ingrese la cantidad',
		                    				checkForZero = 'true',
		                    				errorClass = 'msgErrorDet',
		                    				errorInput = 'inputErrorDet')">
		           						</rich:ajaxValidator>
									</h:inputText>
									<div id="buyDetQuantityMsg" class="inactiveMsg"></div>
								</rich:column>
								<rich:column>
									<a4j:outputPanel id="buyDetCostPanel" >
									<h:inputText value="#{trnPurchase.purchasesDet.grossCost}"
										id="buyDetCost" 
										size="15"
										disabled="#{not empty trnPurchase.purchasesHead.orderHeadData}">
										<a4j:support event="onchange"></a4j:support>
										<rich:ajaxValidator 
		                    			event="onblur"
		                    			onsubmit="validateDecimalField(
		                    				fieldObject = this, 
		                    				fieldMsgId = 'buyDetCostMsg', 
		                    				required = 'true', 
		                    				requiredMsg = 'Favor ingrese el costo',
		                    				checkForZero = 'true',
		                    				errorClass = 'msgErrorDet',
		                    				errorInput = 'inputErrorDet')">
		           						</rich:ajaxValidator>
									</h:inputText>
									</a4j:outputPanel>
									<div id="buyDetCostMsg" class="inactiveMsg"></div>
								</rich:column>
								<rich:column>
									<h:inputText value="#{trnPurchase.purchasesDet.discount}"
										id="buyDetDiscount" 
										size="10"
										disabled="#{not empty trnPurchase.purchasesHead.orderHeadData}">
										<a4j:support event="onchange"></a4j:support>
										<rich:ajaxValidator 
		                    			event="onblur"
		                    			onsubmit="validateDecimalField(
		                    				fieldObject = this, 
		                    				fieldMsgId = 'buyDetDiscountMsg', 
		                    				required = 'false', 
		                    				requiredMsg = 'Favor ingrese el descuento',
		                    				checkForZero = 'negative',
		                    				errorClass = 'msgErrorDet',
		                    				errorInput = 'inputErrorDet')">
		           						</rich:ajaxValidator>
									</h:inputText>
									<div id="buyDetDiscountMsg" class="inactiveMsg"></div>
								</rich:column>
								<rich:column>
									<h:inputText value="#{trnPurchase.purchasesDet.charge}"
										id="buyDetCharge"
										size="10"
										disabled="#{not empty trnPurchase.purchasesHead.orderHeadData}">
										<a4j:support event="onchange"></a4j:support>
										<rich:ajaxValidator 
		                    			event="onblur"
		                    			onsubmit="validateDecimalField(
		                    				fieldObject = this, 
		                    				fieldMsgId = 'buyDetChargeMsg', 
		                    				required = 'false', 
		                    				requiredMsg = 'Favor ingrese el recargo',
		                    				checkForZero = 'negative',
		                    				errorClass = 'msgErrorDet',
		                    				errorInput = 'inputErrorDet')">
		           						</rich:ajaxValidator>
									</h:inputText>
									<div id="buyDetChargeMsg" class="inactiveMsg"></div>
								</rich:column>
							</rich:columnGroup>
						</f:facet>
						<rich:column>
							<h:selectBooleanCheckbox value="#{row.selected}" />
						</rich:column>
						<rich:column rendered="#{not empty trnPurchase.allPurchasesDet}">
							<h:outputText value="#{row.supplyData.descrip}" />
						</rich:column>
						<rich:column rendered="#{not empty trnPurchase.allPurchasesDet}">
							<h:outputText value="#{row.measureUnitData.descrip}" />
						</rich:column>
						<rich:column rendered="#{not empty trnPurchase.allPurchasesDet}">
							<h:outputText value="#{row.taxData.descrip}" />
						</rich:column>
						<rich:column rendered="#{not empty trnPurchase.allPurchasesDet}">
							<h:outputText value="#{row.quantity}" rendered="#{empty trnPurchase.purchasesHead.orderHeadData}"/>
							<rich:inputNumberSpinner 
								value="#{row.quantity}" 
								maxValue="#{row.orderQuantity}" 
								minValue="1" 
								rendered="#{not empty trnPurchase.purchasesHead.orderHeadData}">
								<a4j:support event="onblur"/>
								<a4j:support event="onchange"/>
							</rich:inputNumberSpinner>
						</rich:column>
						<rich:column rendered="#{not empty trnPurchase.allPurchasesDet}">
							<h:outputText value="#{row.grossCost}" />
						</rich:column>
						<rich:column rendered="#{not empty trnPurchase.allPurchasesDet}">
							<h:outputText value="#{row.discount}" />
						</rich:column>
						<rich:column rendered="#{not empty trnPurchase.allPurchasesDet}">
							<h:outputText value="#{row.charge}" />
						</rich:column>
	
						<rich:column rendered="#{not empty trnPurchase.allPurchasesDet}">
							<h:outputText value="#{row.itemAmount}" />
						</rich:column>
					</rich:dataTable>
				</rich:panel>
					<div class="total_values">
						<div class="total_values_fields">
							<s:label for="buyHeadTotal" style="float:left; float:left; margin-right:10px; top:3px;">
								<h:outputText value="Total Compra"/>
							</s:label>
							<h:inputText value="#{trnPurchase.purchasesHead.total}"
								id="buyHeadTotal" required="false" size="10"
								disabled="true">
							<a4j:support event="onchange"></a4j:support>
							</h:inputText>
							<div class="msg_container">
								<rich:message for="buyHeadTotal" />
							</div>
						</div>
						<div class="total_values_fields">
							<s:label for="buyHeadExempt" style="float:left; float:left; margin-right:10px; top:3px;">
								<h:outputText value="Total Exentas"/>
							</s:label>
							<h:inputText value="#{trnPurchase.purchasesHead.exemptTotal}"
								id="buyHeadExempt" required="false" size="10"
								disabled="true">
							<a4j:support event="onchange"></a4j:support>
							</h:inputText>
							<div class="msg_container">
								<rich:message for="buyHeadExempt" />
							</div>
						</div>
						<div class="total_values_fields">
							<s:label for="buyHeadTax" style="float:left; float:left; margin-right:10px; top:3px;">
								<h:outputText value="Total IVA"/>
							</s:label>
							<h:inputText value="#{trnPurchase.purchasesHead.taxTotal}"
								id="buyHeadTax" required="false" size="10"
								disabled="true">
							<a4j:support event="onchange"></a4j:support>
							</h:inputText>
							<div class="msg_container">
								<rich:message for="buyHeadTax" />
							</div>
						</div>
					</div>
				</a4j:outputPanel>
			</a4j:region>
			<s:decorate template="/layout/displayButton.xhtml" styleClass="button_form" style="width:198px;">
				<a4j:commandButton value="Guardar" id="saveRegBtn"
					action="#{trnPurchase.saveNewData()}"
					reRender="BuyForm"
					styleClass="button"
					onclick="onRequestStart();"
					oncomplete="onRequestEnd('j_id740:BuyForm', 15, #{trnPurchase.validateEntireForm});"
					/>
				<rich:spacer width="10px" />
				<a4j:commandButton value="Cancelar" id="cancelBtn"
					onclick="#{rich:component('PurchaseConfirmationModalPanel')}.show()"
					styleClass="button" />
			</s:decorate>
			
			<a4j:commandLink
					id="buyCloseBtn"
					styleClass="button"
					onclick="#{rich:component('PurchaseCloseModalPanel')}.show()" 
					style="position:relative; float:right; right:15px; margin-top:15px;">
					<h:graphicImage value="/img/icons/close.png"/>
			</a4j:commandLink>
		</a4j:form>
		
		
		<rich:modalPanel  id="PurchaseConfirmationModalPanel"
			resizeable="false" 
			autosized="true" 
			moveable="false" 
			style="border:2px solid #6FADDF">
			<a4j:form>
			<div class="globalMessage">
				<h:outputText value="Esta seguro que desea cancelar la operacion?" />
			</div>
			<s:decorate template="/layout/displayButton.xhtml" styleClass="trn_button_form"  style="width:270px; margin-top:0px; margin-left:auto; text-align:center;">
				<a4j:commandButton
					action="#{trnPurchase.cancelData()}"
					value="Aceptar" 
					id="PurchaseAcceptConfirmation"
					reRender="BuyForm"
					oncomplete="#{rich:component('PurchaseConfirmationModalPanel')}.hide()"
					styleClass="button"/>
				<rich:spacer width="20px" />
				<a4j:commandButton value="Cancelar" id="PurchaseCancelConfirmation"
					onclick="#{rich:component('PurchaseConfirmationModalPanel')}.hide()"
					styleClass="button" />
			</s:decorate>
			</a4j:form>
		</rich:modalPanel>
		
		<rich:modalPanel  id="PurchaseCloseModalPanel"
			resizeable="false" 
			autosized="true" 
			moveable="false"
			style="border:2px solid #6FADDF;">
			<a4j:form>
			<div class="globalMessage">
				<h:outputText value="Esta seguro que desea cancelar la operacion?"/>
			</div>
			<center>
			<s:decorate template="/layout/displayButton.xhtml" styleClass="trn_button_form"  style="width:270px; margin-top:0px; margin-left:auto; text-align:center;">
				<a4j:commandButton
					action="#{trnPurchase.cancelData()}"
					value="Aceptar" 
					id="PurchaseAcceptClose"
					reRender="BuyForm"
					oncomplete="#{rich:component('PurchaseCloseModalPanel')}.hide();#{rich:component('modalBuy')}.hide();"
					styleClass="button"/>
				<rich:spacer width="20px" />
				<a4j:commandButton value="Cancelar" id="PurchaseCancelClose"
					onclick="#{rich:component('PurchaseCloseModalPanel')}.hide()"
					styleClass="button" />
			</s:decorate>
			</center>
			</a4j:form>
		</rich:modalPanel>
		
		<rich:modalPanel
			id="supplierPickModalPanel"
			width="420"
			height="320"
			resizeable="false">
			<f:facet name="header">
				<h:panelGroup>
					<h:outputText value="Proveedor" />
				</h:panelGroup>
			</f:facet>
			<f:facet name="controls">
				<h:panelGroup>
					<h:graphicImage value="/img/close.png" style="cursor:pointer"
						id="supplierPickModalPanelHide">
					</h:graphicImage>
					<rich:componentControl for="supplierPickModalPanel"
						attachTo="supplierPickModalPanelHide" operation="hide" event="onclick" />
				</h:panelGroup>
			</f:facet>
			<h:panelGroup id="supplierPickModalPanelEdit">
			<!--  **** Include of the update page ****  -->
				<a4j:include viewId="/fms/com/transactions/comSupplierList.xhtml" />
			</h:panelGroup>
			<s:decorate template="/layout/displayButton.xhtml" styleClass="button_form" style="width:270px;">
				<a4j:form>
				<a4j:commandButton value="Aceptar" id="acceptSelectedSupplier"
					action="#{trnPurchase.selectSupplier(trnPurchase.selectHolder.supplierPickData)}"
					reRender="BuyForm, buyHeadSupplier"
					styleClass="button"
					oncomplete="if(#{empty facesContext.maximumSeverity}) #{rich:component('supplierPickModalPanel')}.hide();"/>
				<rich:spacer width="20px" />
				<a4j:commandButton value="Cancelar" id="cancelBtn"
					styleClass="button" />
				</a4j:form>
			</s:decorate>
		</rich:modalPanel>

</ui:composition>
